package com.bigknow.appstore.proxy.handler.init;

import com.bigknow.appstore.proxy.cache.ICacheManager;
import com.bigknow.appstore.proxy.handler.base.BaseInboundHandler;
import com.bigknow.appstore.proxy.log.ILogWriter;
import com.bigknow.appstore.proxy.server.IProxyServer;
import com.bigknow.appstore.proxy.util.HandlerVariables;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpMessage;

/**
 * 清空线程的变量
 * Created by chaos on 2016/9/19.
 */
@ChannelHandler.Sharable
public class ClearVariablesHandler extends BaseInboundHandler {

    public ClearVariablesHandler(IProxyServer proxyServer, ICacheManager cacheManager, ILogWriter writer) {
        super(proxyServer, cacheManager, writer);
    }

    @Override
    public void read(ChannelHandlerContext ctx, FullHttpMessage msg) throws Exception {
        HandlerVariables.currentRequestVoLocal.remove();
        ctx.fireChannelRead(msg);
    }
}
